package com.apeli.model;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;
import java.util.Locale;

public class Employee implements ApplicationContextAware , InitializingBean {
    private Order order;
    private ApplicationContext context;
    public void init() {
        System.out.println("employee 开始初始化前..." + context.getMessage("aa", new Object[]{}, Locale.CHINESE));
    }
    @Autowired
    public void setOrder(Order order) {
        System.out.println("依赖注入....");
        this.order = order;
    }

    public Employee() {
        System.out.println("构造方法...");
    }
    public void after() {
        System.out.println("employee 开始初始化后..." + context.getMessage("aa", new Object[]{}, Locale.CHINESE));
    }
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.context = applicationContext;
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println("调用init Bean..");
    }
    @PostConstruct
    public void test() {
        System.out.println("aware" + context.getMessage("aa", new Object[]{}, Locale.CHINESE)+"调用PostConstruct....");

    }

}
